package com.intretech.umsin.code.generator.provider;

import org.springframework.stereotype.Component;

/**
 * @version V1.0
 * @ClassName: DbDataTypeToJavaDataType
 * @Description:(数据库中的数据类型转为Java中的数据类型)
 * @author: 李启联
 * @date: 2020-03-06 11:33
 * @Copyright: Copyright (c), 2020
 */
@Component
public class DbDataTypeToJavaDataType {

    public String getDataType(String type) {
        switch (type.toUpperCase()) {
            case "VARCHAR":
            case "CHAR":
            case "TEXT":
            case "NCHAR":
            case "VARCHAR(MAX)":
            case "NVARCHAR":
            case "NVARCHAR(MAX)":
            case "NTEXT":
            case "UNIQUEIDENTIFIER":
            case "XML":
                return "String";

            case "BLOB":
            case "BINARY":
            case "IMAGE":
            case "VARBINARY(MAX)":
                return "byte[]";

//            case "INT":
//                return "Long";
            case "BIGINT":
                return "Long";
            case "TINYINT":
            case "SMALLINT":
            case "MEDIUMINT":
            case "INT":
                return "Integer";
            case "BIT":
            case "BOOLEAN":
            case "BOOL":
                return "Boolean";
            case "FLOAT":
            case "REAL":
                return "Float";
            case "DOUBLE":
                return "Double";
            case "DECIMAL":
            case "NUMERIC":
                return "java.math.BigDecimal";

            case "DATETIME":
            case "DATETIME2":
            case "SMALLDATETIME":
            case "TIMESTAMP":
            case "DATE":
                return "java.time.LocalDateTime";

            default:
                return "Object";
        }
    }
}